@extends('layouts.header')
@section('content')
    <div class="page-container">
        <form class="form form-horizontal" id="form">
            <b class="c-red">日期格式，如：{{date('Y-m-d')}} </b>
            @foreach($params as $key => $param_must)
                @php 
                    $params = explode('&&',$param_must);
                    $param = array_get($params,0,'');
                    $required = array_get($params,1,0) ? 'required' : '';
                    $value = strstr($key,'日期') > -1 ? date('Y-m-d') : '';
                @endphp 
            <div class="row cl">
                <label class="form-label col-xs-3">{{$key}}：</label>
                <div class="formControls col-xs-7">
                    <input class="input-text {{$required}}" type="text" name="params[{{$param}}]" value="{{$value}}">
                </div>
            </div>
            @endforeach
            <div class="row cl text-c">
                <b class="btn btn-primary radius" onclick="getThirdDj({{request('third_id')}})">确定</b>
            </div>
        </form>
    </div>

    <script type="text/javascript">
        function getThirdDj(thirdId){
            let formId='form', formData = $('#'+formId).serialize() ;
            formData += '&third_id='+thirdId;
            if (!$('#'+formId).valid()) {
                layer.msg("验证失败");  
                return false;
            }
            ajax('post','index',formData,function(res){
                let total = parseInt(res);
                if(!$.isNumeric(total)){
                    layer.confirm(res);
                    return false;
                }
                layer.confirm('导入样品量：'+total,{
                    btn:['确定'],
                    btn1:function () {
                        parent.location.reload();
                    }
                });
            },0);
        }
    </script>

@endsection

